package com.servlet;

import com.alibaba.fastjson.JSONObject;
import com.server.ServletUrlTools;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/saved_games")//查询此玩家保存的键盘 GET /saved_games/{userName}
public class SaveServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws IOException {
        req.setCharacterEncoding("UTF-8");
        String url=req.getRequestURI();

        url=ServletUrlTools.unescape(url);System.out.println(url);
        String[] urls= url.split("/");

        resp.setCharacterEncoding("UTF-8");
        resp.setHeader("Access-Control-Allow-Origin", "*");
        resp.setHeader("Access-Control-Allow-Methods", "POST,GET,PUT,DELETE");
        resp.setHeader("Access-Control-Max-Age", "3600");
        resp.setHeader("Access-Control-Allow-Headers", "*");
        resp.setHeader("Access-Control-Allow-Credentials", "true");
        JSONObject rmsg=new JSONObject();
        //{match_token:"棋局token"}的数组
        //未完
        if(rmsg!=null)
            resp.getWriter().write(rmsg.toJSONString());
    }
}
